/*
 * Class used in parsing the SQL query. This will store the position of each keyword in the query
 */

package com.querie.parser;

/**
 *
 * @author a-skoshy
 */
public class LogicWord implements Comparable<LogicWord>{

    public String getLogicWord() {
        return logicWord;
    }
    private String logicWord;
    private int startChar;
    private int endChar;

    public LogicWord(String word, int startChar, int endChar) {
        this.logicWord = word;
        this.startChar = startChar;
        this.endChar = endChar;
    }

    public int compareTo(LogicWord obj) throws ClassCastException {
        int otherStartChar = ((LogicWord) obj).getStartChar();

        if (this.startChar < otherStartChar) {
            return -1;

        } else if (this.startChar > otherStartChar) {
            return 1;
        } else {
            return 0;
        }
    }

    public int getStartChar() {
        return startChar;
    }

    public int getEndChar() {
        return endChar;
    }

    

    public String toString() {
        return "Logicword:" + logicWord + " Start:" + startChar + " End:" + endChar + "\n";
    }
}
